<template>
  <basic-dialog
    :visible="visible"
    :title="'提示'"
    :ok-text="'确认'"
    :show-close="false"
    :loadingBtn="pushDownLoading"
    :handle-ok="handleSave"
    :handle-close="onCancel"
    :width="'30%'"
  >
    <div class="form-container">
      <el-form
        ref="checkForm"
        :model="checkForm"
        :rules="formValidate"
        label-position="top"
      >
        <el-card
          class="supplier-info"
          shadow="hover"
        >
          <div slot="header">
            <!-- <span class="title">当前采购订单发票类型为：无税票，需要填写原因进行无税票审批</span> -->
            <span class="title">{{message}}</span>
          </div>
          <el-form-item label="审批原因：" prop="pushOaRemark">
            <el-input v-model.trim="checkForm.pushOaRemark" type="textarea"></el-input>
          </el-form-item>
        </el-card>
      </el-form>
    </div>
  </basic-dialog>
</template>
<script>
import BasicDialog from '../../../../components/BasicDialog';
import { mapState } from 'vuex';

export default {
  name: 'CheckApprovalDialog',
  components: {
    BasicDialog,
  },
  props: {
    dialogVisible: {
      type: Boolean,
    },
    message: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      checkForm: {
        pushOaRemark: '',
      },
      formValidate: {
        pushOaRemark: [
          { required: true, message: '审批原因不能为空', trigger: 'change' },
        ],
      },
    };
  },
  computed: {
    ...mapState({
      pushDownLoading: (state) => state.sourcing.purchaseInquiry.pushDownLoading,
    }),
    visible () {
      return this.dialogVisible;
    },
  },
  methods: {
    onCancel () {
      this.$emit('hide-handler');
    },
    handleSave () {
      this.$refs.checkForm.validate((valid) => {
        if (valid) {
          this.$emit('confirm-submit', this.checkForm)
        }
      });
    }
  },
};
</script>
<style lang="less">
.form-container {
  .supplier-info {
    margin-bottom: 10px;
  }
}
</style>
